import { homeBrand } from '../api/home'
const state = {
  brandList: []
}
const mutations = {
  setBrandList (state, value) {
    state.brandList = value
  }
}
const actions = {
  async getBrandList ({ state, commit }) {
    if (state.brandList.length > 0) {
      return state.brandList
    }
    const { result } = await homeBrand(10)
    commit('setBrandList', result)
    return result
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
